package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;

import com.jp.knowledge.R;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.OrderModel;

import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/5/9.
 */

public class OrderDetailRelationAdapter extends RecycleVAdapter<OrderModel.RelationListBean> {

    public OrderDetailRelationAdapter(Context context, @NonNull List<OrderModel.RelationListBean> list) {
        super(context, list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_order_detail_relation;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        OrderModel.RelationListBean data = getData(position);
        String iconUrl = data.getIcon();
        holder.setImageUrl(R.id.orderDetailRelationSingleIcon, data.getIcon());
        if(data.getName() == null || data.getName().trim().length() == 0){
            holder.get(R.id.orderDetailRelationSingleTitle).setVisibility(View.GONE);
        } else{
            holder.get(R.id.orderDetailRelationSingleTitle).setVisibility(View.VISIBLE);
            holder.setTextView(R.id.orderDetailRelationSingleTitle, data.getName());
        }
        if(data.getCompanyName() == null || data.getCompanyName().trim().length() == 0){
            holder.get(R.id.orderDetailRelationSingleDesc).setVisibility(View.GONE);
        } else{
            holder.get(R.id.orderDetailRelationSingleDesc).setVisibility(View.VISIBLE);
            holder.setTextView(R.id.orderDetailRelationSingleDesc, data.getCompanyName());
        }
    }
}
